<?php
getHeader();

if (isset($_POST['competitionName']))
{
	$comp = compProf::getCompetitionByCid((int)$_POST['cid']);
	$comp->description = $_POST['competitionDescription'];
	$comp->name = $_POST['competitionName'];
	if ($comp->update())
	{
		?>
<div id="content">
<div class="tabs headTabs"><span>编辑比赛</span></div>
<div class="dataList"><span>编辑成功</span></div>
</div>
		<?php
	}
	else
	{
		?>
<div id="content">
<div class="tabs headTabs"><span>编辑比赛</span></div>
<div class="dataList"><span>编辑失败</span></div>
</div>
		<?php
	}
}
else if (isset($_GET['cid']))
{
	$comp = compProf::getCompetitionByCid((int)$_GET['cid']);
	if (isset($_SESSION['authPassed']) && $comp->admin == $_SESSION['uid'])
	{
		?>
<div id="content">
<div class="tabs headTabs"><span>编辑比赛</span></div>
<div class="dataList">
<link rel="stylesheet"
	href="<?php echo PLUGINURL; ?>tinyEditor/style.css" />
<script type="text/javascript"
	src="<?php echo PLUGINURL; ?>tinyEditor/tinyeditor.js"></script>
<ul>
	<form action='?p=editCompetition' method="post" class='postForm'>
	<li>比赛名称: <input type='text' name='competitionName' class='postInput'
		value='<?php echo $comp->name; ?>' /></li>
	<li><input type='hidden' name='cid' value=<?php echo $_GET['cid']; ?> /></li>
	<li>比赛描述: <textarea name='competitionDescription' id="tinyInput"><?php echo $comp->description; ?></textarea><?php getEditor(); ?></li>
	<li><br />
	<input type="submit" value="提交修改" class="button"
		style='margin-left: 40px;' onclick="instance.post();" /></li>
	</form>
</ul>
</div>
</div>
		<?php
	}
}
getPanel();
getFooter();
?>